package org.robotlegs.base
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import org.robotlegs.core.IContext;
	
	
public class ContextBase implements IContext, IEventDispatcher
{
	public function ContextBase()
	{
		_eventDispatcher = new EventDispatcher(this);
	}
	


	protected var _eventDispatcher:IEventDispatcher;

	
	
	public function get eventDispatcher():IEventDispatcher
	{
		return _eventDispatcher;
	}

	
	public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
	{
		eventDispatcher.addEventListener(type, listener, useCapture, priority);
	}
	

	public function dispatchEvent(event:Event):Boolean
	{
		if(eventDispatcher.hasEventListener(event.type))
			return eventDispatcher.dispatchEvent(event);
		return false;
	}
	

	public function hasEventListener(type:String):Boolean
	{
		return eventDispatcher.hasEventListener(type);
	}
	

	public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
	{
		eventDispatcher.removeEventListener(type, listener, useCapture);
	}
	

	public function willTrigger(type:String):Boolean
	{
		return eventDispatcher.willTrigger(type);
	}
}
}
